
var qcloud = require('../vendor/wafer2-client-sdk/index')
var config = require('../config')
var util = require('../utils/util.js')

const recordService = {
  get: function(openId, callback) {
    qcloud.request({
      url: `${config.service.recordUrl}?open_id=${openId}`,
      login: true,
      success(result) {
        callback(result)
      },
      fail(error) {
        util.showModel('请求失败', error)
        console.log('request fail', error)
      }
    })
  },
  update: function(record, callback) {
    qcloud.request({
      url: config.service.recordUrl,
      login: true,
      method: 'Put',
      data: record,
      success(result) {
        callback(result)
      },
      fail(error) {
        util.showModel('请求失败', error)
        console.log('request fail', error)
      }
    })
  }
}

module.exports = recordService